package com.mohan.listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.mohan.lucene.LuceneInit;
import com.mohan.service.ArticleService;


public class SqlContextListener implements ServletContextListener {

	@Override
	public void contextInitialized(ServletContextEvent sce) {
		// TODO Auto-generated method stub
		
//		ServletContext context = sce.getServletContext();
//		ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context);
//		ArticleService mService = (ArticleService) ctx.getBean("articleService");
//		
//		
//		try {
//			LuceneInit.BuildDbIndex(mService,LuceneInit.articleRamDir);
//		} catch (Exception e) {
//			// TODO: handle exception
//			e.printStackTrace();
//		}
	}

	@Override
	public void contextDestroyed(ServletContextEvent sce) {
		// TODO Auto-generated method stub
		
	}
	
}
